    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <script type="text/javascript">
            window.addEventListener("load",eventWindowLoaded,false);
            function eventWindowLoaded(){
                drawScreen();
            }
            function drawScreen(){
                var theCanvas=document.getElementById("canvas");
                var context=theCanvas.getContext("2d");

                var gr = context.createLinearGradient(0,0,100,0);

                gr.addColorStop(0,'rgb(255,0,0)');
                gr.addColorStop(.5,'rgb(0,255,0)');
                gr.addColorStop(1,'rgb(255,0,0)');

                context.fillStyle = gr;
                context.beginPath();
                context.moveTo(0,0);
                context.lineTo(50,0);
                context.lineTo(100,50);
                context.lineTo(50,100);
                context.lineTo(0,100);
                context.lineTo(0,0);
                context.stroke();
                context.fill();
                context.closePath();
            }
            </script>
    </head>
    <body>
        <div style="position:absolute;top:50px;left:50px">
            <canvas id="canvas" height="500" width="500">Your browser does not support HTML5 Canvas.</canvas>
        </div>
    </body>
    </html>